package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class EditTextActivity extends AppCompatActivity {
    private Drawable drawable;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_edit_text);
        TextView txt = findViewById(R.id.txt);
        EditText editText = findViewById(R.id.edit_text01);
        EditText editText2 = findViewById(R.id.edit_text02);
        Button buttonGetText = findViewById(R.id.button_getText);
        editText.setHint("这是一个输入框");
//        editText.setTextColor(Integer.parseInt("#FFFF0000"));
        editText.setInputType(0);
        drawable = getResources().getDrawable(R.drawable.ic_launcher_foreground);
        editText.setCompoundDrawables(drawable,null,null,null);
        editText.setPadding(16,10,16,10);
//        editText.setBackgroundColor(Integer.parseInt("#FFFF0000"));
        buttonGetText.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String text = editText.getText().toString();
                String text2 = editText2.getText().toString();
                Log.v("TAG", "onClick:"+"用户名："+text+"密码："+text2);
                txt.setText("用户名："+text+"密码："+text2);
            }
        });


    }
}